package com.rinlink.jbcodec.creator;

import com.alibaba.fastjson.JSONObject;
import com.rinlink.jbcodec.exception.AttributePropertyException;
import com.rinlink.jbcodec.transform.BytesToHexString;
import com.rinlink.jbcodec.transform.Transform;

import java.nio.ByteBuffer;

public class ByteBufferToHexStringCreator extends ByteBufferToObjectCreator {

    @Override
    protected Transform create(JSONObject attr, ByteBuffer data, JSONObject t) {
        Integer bytes = attr.getInteger("bytes");
        if (bytes == null)
            throw new AttributePropertyException("bytes");
        return new BytesToHexString(data,bytes);
    }

}
